package usersManagement.controller;

import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import usersManagement.util.AppLog;

import javax.enterprise.inject.Model;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;

@Model
@Named("index")
public class IndexController {

    @Inject
    private FacesContext facesContext;

    @Inject @AppLog
    private Logger log;

    private int count ;
    private long elapsed ;

    public void openDialog() {

        log.info("Opening sample dialog");

        count = 0 ;
        elapsed = System.currentTimeMillis() ;

        for (int i = 0; i < 10000; i++) {
            try {
                Thread.sleep(1);
                count +=1 ;
            }
            catch (InterruptedException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        }

        elapsed = System.currentTimeMillis() - elapsed ;
    }

    public void closeDialog() {

        log.info("Closing sample dialog");
    }

    public int getCount() {

        return count;
    }

    public void setCount(int count) {

        this.count = count;
    }

    public long getElapsed() {

        return elapsed;
    }

    public void setElapsed(long elapsed) {

        this.elapsed = elapsed;
    }
}
